/*
 * @(#)GenericHibernateService.java 2009-3-23
 * Copyright (c) 2008-2015 by CJK
 * All rights reserved.
 */
package net.beyond.common.ssh;

import java.util.List;

import net.jk.util.page.PaginationSupport;

import org.hibernate.criterion.DetachedCriteria;

/**
 * 扩展了Service，添加HibernateRepository支持的操作
 * 
 * @author Shmiluyu
 * @version 1.000 2009-3-23
 */
public interface HibernateService<T> extends Service<T, String> {

	/**
	 * 保存或者更新参数实体
	 * 
	 * @param newInstance
	 * @return
	 */
	void saveOrUpdate(T newInstance);

	/**
	 * 条件查询
	 * 
	 * @param detachedCriteria
	 * @return
	 */
	List<T> findAllByCriteria(final DetachedCriteria detachedCriteria);

	/**
	 * 分页条件查询
	 * 
	 * @param detachedCriteria
	 * @param pageSize
	 * @param startIndex
	 * @return
	 */
	PaginationSupport<T> findPageByCriteria(
			final DetachedCriteria detachedCriteria, final int pageSize,
			final int startIndex);

	/**
	 * 查询记录条数
	 * 
	 * @param detachedCriteria
	 * @return
	 */
	int getCountByCriteria(final DetachedCriteria detachedCriteria);

	/**
	 *分页条件查询
	 * 
	 * @param detachedCriteria
	 * @param startIndex
	 * @return
	 */
	PaginationSupport<T> findPageByCriteria(
			final DetachedCriteria detachedCriteria, final int startIndex);

	/**
	 * 分页条件查询
	 * 
	 * @param detachedCriteria
	 * @return
	 */
	PaginationSupport<T> findPageByCriteria(
			final DetachedCriteria detachedCriteria);
}
